'use strict'

###*
 # @ngdoc directive
 # @name xoceanApp.directive:include
 # @description
 # # include
 # Used in the directive 'template-box'
 # Instead of 'ng-include', with same usage
 # Preventing the wrapper created by 'ng-include'
###
angular.module('xoceanApp')
  .directive('include', ($http, $templateCache, $compile)->
    restrict: 'A'
    link: (scope, elem, attrs)->
      templateUrl = scope.$eval(attrs.include)
      $http.get(templateUrl, {cache: $templateCache}).success (tplContent)->
        # tplContent = tplContent.replace(/<%script>/g, '</script>')
        scope.now = Date.now()
        elem.replaceWith $compile(tplContent)(scope)
        return
      return
  )
